Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step 2 #1

Open
wants to merge 9 commits into
base: step-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Default excludes
#

# Binaries
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.war
*.ear
*.sar
*.class

# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties

# IntelliJ project files
*.iml
*.iws
*.ipr
.idea/

# eclipse project file
.settings/
.classpath
.project

# OS
.DS_Store

# Misc
*.swp
transaction.log
54 changes: 43 additions & 11 deletions tutorial-juzcret/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
</properties>

<dependencies>

<!-- Application dependencies-->
<dependency>
<groupId>org.juzu</groupId>
Expand All @@ -29,6 +28,23 @@
<artifactId>juzu-plugins-servlet</artifactId>
<version>1.0.0-cr1</version>
</dependency>
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-plugins-less4j</artifactId>
<version>1.0.0-cr1</version>
</dependency>
<dependency>
<groupId>org.exoplatform.kernel</groupId>
<artifactId>exo.kernel.container</artifactId>
<version>2.4.x-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- Groovy is shipped with GateIn -->
<dependency>
Expand Down Expand Up @@ -83,16 +99,32 @@
</dependencies>

<build>
<finalName>tutorial-juzcret</finalName>

<pluginManagement>
<plugins>


</plugins>
</pluginManagement>

<finalName>tutorial-juzcret</finalName>

<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sources>
<fileset>
<directory>${project.build.outputDirectory}</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</fileset>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2012 eXo Platform SAS.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.exoplatform.commons.juzu;

import javax.inject.Provider;
import juzu.inject.ProviderFactory;
import org.exoplatform.container.PortalContainer;
import org.picocontainer.ComponentAdapter;

/**
* Provides kernel services in Juzu application.
*
* @author <a href="mailto:[email protected]">Frederic Drouet</a>
*/
public class KernelProviderFactory implements ProviderFactory {

@Override
public <T> Provider<? extends T> getProvider(final Class<T> implementationType) throws Exception {
final PortalContainer container = PortalContainer.getInstance();
if (container == null) {
throw new IllegalStateException("Not running in the context of a portal container");
}
final ComponentAdapter adapter = container.getComponentAdapterOfType(implementationType);
if (adapter != null) {
return new Provider<T>() {
@Override
public T get() {
Object service = adapter.getComponentInstance(container);
if (service == null) {
throw new RuntimeException("Could not obtain service " + implementationType + " from container " + container);
}
return implementationType.cast(service);
}
};
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2013 eXo Platform SAS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.juzu.tutorial;

import javax.inject.Inject;

import juzu.Action;
import juzu.Path;
import juzu.Response;
import juzu.View;

import org.juzu.tutorial.services.SecretService;

public class JuZcretApplication {

@Inject
SecretService secretService;

@Inject
@Path("secretWall.gtmpl")
org.juzu.tutorial.templates.secretWall secretWall;

@Inject
@Path("addSecret.gtmpl")
org.juzu.tutorial.templates.addSecret addSecret;

@View
public Response.Content index() {
return secretWall.with().secretsList(secretService.getSecrets()).ok();
}

@View
public Response.Content addSecretForm() {
return addSecret.ok();
}

@Action
public Response.View addSecret(String msg, String imgURL) {
secretService.addSecret(msg, imgURL);
return JuZcretApplication_.index();
}
}
Loading