This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from metacosm/master
GTNWSRP-289
- Loading branch information
Showing
21 changed files
with
601 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
api/src/main/java/org/gatein/wsrp/api/plugins/AbstractPlugins.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* JBoss, a division of Red Hat | ||
* Copyright 2012, Red Hat Middleware, LLC, and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.gatein.wsrp.api.plugins; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */ | ||
public abstract class AbstractPlugins implements Plugins | ||
{ | ||
private static final List<String> KNOWN_PLUGIN_INTERFACES = new ArrayList<String>(3); | ||
static | ||
{ | ||
KNOWN_PLUGIN_INTERFACES.add("org.gatein.registration.RegistrationPolicy"); | ||
KNOWN_PLUGIN_INTERFACES.add("org.gatein.registration.policies.RegistrationPropertyValidator"); | ||
KNOWN_PLUGIN_INTERFACES.add("org.gatein.wsrp.api.extensions.InvocationHandlerDelegate"); | ||
} | ||
|
||
@Override | ||
public List<String> getKnownPluginInterfaceNames() | ||
{ | ||
return Collections.unmodifiableList(KNOWN_PLUGIN_INTERFACES); | ||
} | ||
|
||
@Override | ||
public List<String> getPluginImplementationNames(Class pluginClass, String defaultImplementationClassName) | ||
{ | ||
try | ||
{ | ||
// find all available implementations, including at least the default one | ||
final List<String> implementations = getImplementationNamesFor(pluginClass.getCanonicalName(), defaultImplementationClassName); | ||
// sort alphabetically | ||
Collections.sort(implementations); | ||
|
||
return implementations; | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
protected abstract List<String> getImplementationNamesFor(String pluginClassName, String defaultImplementationClassName); | ||
|
||
@Override | ||
public <T> T createPluginInstance(String className, Class<T> pluginClass) | ||
{ | ||
try | ||
{ | ||
final Class<? extends T> clazz = getImplementationNamed(className, pluginClass); | ||
if (!pluginClass.isAssignableFrom(clazz)) | ||
{ | ||
throw new IllegalArgumentException("Class does not implement" + pluginClass.getCanonicalName()); | ||
} | ||
else | ||
{ | ||
return pluginClass.cast(clazz.newInstance()); | ||
} | ||
} | ||
catch (ClassNotFoundException e) | ||
{ | ||
throw new IllegalArgumentException("Couldn't find class " + className, e); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new IllegalArgumentException("Couldn't instantiate class " + className, e); | ||
} | ||
} | ||
|
||
protected abstract <T> Class<? extends T> getImplementationNamed(String className, Class<T> pluginClass) throws ClassNotFoundException; | ||
} |
37 changes: 37 additions & 0 deletions
37
api/src/main/java/org/gatein/wsrp/api/plugins/Plugins.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* JBoss, a division of Red Hat | ||
* Copyright 2012, Red Hat Middleware, LLC, and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.gatein.wsrp.api.plugins; | ||
|
||
import java.util.List; | ||
|
||
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */ | ||
public interface Plugins | ||
{ | ||
String WSRP_PLUGIN_EXTENSION_SUFFIX = ".wsrp.jar"; | ||
|
||
List<String> getKnownPluginInterfaceNames(); | ||
|
||
List<String> getPluginImplementationNames(Class pluginClass, String defaultImplementationClassName); | ||
|
||
<T> T createPluginInstance(String className, Class<T> pluginClass); | ||
} |
50 changes: 50 additions & 0 deletions
50
api/src/main/java/org/gatein/wsrp/api/plugins/PluginsAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* JBoss, a division of Red Hat | ||
* Copyright 2012, Red Hat Middleware, LLC, and individual contributors as indicated | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.gatein.wsrp.api.plugins; | ||
|
||
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */ | ||
public class PluginsAccess | ||
{ | ||
private static Plugins plugins; | ||
|
||
private PluginsAccess() | ||
{ | ||
} | ||
|
||
public synchronized static Plugins getPlugins() | ||
{ | ||
return plugins; | ||
} | ||
|
||
public synchronized static void register(Plugins plugins) | ||
{ | ||
if (PluginsAccess.plugins == null) | ||
{ | ||
PluginsAccess.plugins = plugins; | ||
} | ||
else | ||
{ | ||
throw new IllegalStateException("A Plugins implementation (" + plugins.getClass().getCanonicalName() + ") has already been provided"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>wsrp-examples</artifactId> | ||
<groupId>org.gatein.wsrp</groupId> | ||
<version>2.2.0.Beta06-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<name>GateIn WSRP Examples: InvocationHandlerDelegate Implementation</name> | ||
<artifactId>wsrp-invocation-handler-delegate-example</artifactId> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.gatein.wsrp</groupId> | ||
<artifactId>wsrp-integration-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> |
Oops, something went wrong.